<html><head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  <title>客服聊天系统</title>
  <script type="text/javascript">
  //WebSocket = null;
  </script>
  <link href="{$public}/assets/css/bootstrap.min.css" rel="stylesheet">
  <link href="{$public}/assets/css/style.css?v=20171021" rel="stylesheet">
  <!-- Include these three JS files: -->
  <script type="text/javascript" src="{$public}/assets/js/swfobject.js"></script>
  <script type="text/javascript" src="{$public}/assets/js/web_socket.js"></script>
  <script type="text/javascript" src="{$public}/assets/js/jquery.min.js"></script>
  <script type="text/javascript">
    if (typeof console == "undefined") {    this.console = { log: function (msg) {  } };}
    // 如果浏览器不支持websocket，会使用这个flash自动模拟websocket协议，此过程对开发者透明
    WEB_SOCKET_SWF_LOCATION = "{$public}/assets/swf/WebSocketMain.swf";
    // 开启flash的websocket debug
    WEB_SOCKET_DEBUG = true;
    var cheakpwd_link = "{:cmf_plugin_url('LyzKefuChat://Index/checkPWD')}";  //检测客服密码是否正确
    var ws, name, client_list={},room_id,kefu;
    var img = "<?php echo rand(1,10);?>.jpg";  //获取随机图片
    var kefu_id = "<?php echo !empty($_GET['kefu_id']) ? $_GET['kefu_id'] : '';?>";
    var user_name = "{$kefu_name||default=''}";
    var user_pwd = "{$kefu_pwd||default=''}";

    room_id = "<?php echo isset($_GET['room_id']) ? $_GET['room_id'] : 1?>";
    kefu = "<?php echo !empty($_GET['kefu']) ? $_GET['kefu'] : '';?>";
    $(function(){
    	select_client_id = 'all';
	    $("#client_list").change(function(){
	         select_client_id = $("#client_list option:selected").attr("value");
	    });
        //点击客服随机分配房间id
        $(".user_roomid").click(function(){
            var kefu_id = $(this).attr('data-id');
            $(this).attr("href","{:cmf_plugin_url('LyzKefuChat://Index/chat')}?room_id=<?php echo rand(1,100).time();?>&kefu_id="+kefu_id);
            //console.log($(this).attr('href'));
        });
    });
  </script>
<!--主要的聊天js-->
<script type="text/javascript" src="{$public}/assets/js/chat.js"></script>
</head>
<body onload="connect();">
    <div class="container" style="margin-top: 10px;">
	    <if class="row clearfix">
            <div class="col-md-3 column">
                <div class="thumbnail">
                    <div class="caption" id="userlist1">
                        <h4>客服列表</h4>
                        <foreach name="user_list" item="vo">
                            <li data-id="{$vo.user_id}">
                                <if condition="$vo.login_status == 1">
                                <a href="javascript:;" class="user_roomid" data-id="{$vo['user_id']}" target="_blank">{$vo.user_name}</a>&nbsp;&nbsp;
                                    <span style="color: #1dc116;">在线</span>
                                <else/>
                                    <a href="#">{$vo.user_nickname}</a>&nbsp;&nbsp;
                                    <span style="color:red;">不在线</span>
                                </if>

                            </li>
                        </foreach>
                    </div>
                </div>
            </div>
	        <div class="col-md-6 column">
	           <div class="thumbnail">
	               <div class="caption" id="dialog" style="overflow:scroll;height: 400px;"></div>
	           </div>
                <if empty($_GET['kefu'])>
	           <form onsubmit="onSubmit(); return false;">
                   <select style="margin-bottom:8px" id="client_list">
                       <option value="all">所有人</option>
                   </select>
                    <textarea class="textarea thumbnail" id="textarea" onkeydown= "javascript:if(event.ctrlKey && event.keyCode==13)onSubmit1();"></textarea>
                    <div class="say-btn"><input type="submit" class="btn btn-default" value="发表" /></div>
               </form>
                <else/>
                <form onsubmit="onSubmit1(); return false;">
                    <textarea class="textarea thumbnail" id="textarea" onkeydown= "javascript:if(event.ctrlKey && event.keyCode==13)onSubmit1();"></textarea>
                    <div class="say-btn"><input type="submit" class="btn btn-default" value="发表" /></div>
                </form>
                </if>
	        </div>
            <!--在线用户列表-->
            <div class="col-md-3 column">
                <div class="thumbnail">
                    <div class="caption" id="userlist">
                    </div>
                </div>
            </div>

	    </div>
    </div>
    <h2 style="text-align: center;"><a href="http://www.liyuzhao.cn/blog/?id=52" target="_blank">可以去我博客看一下http://www.liyuzhao.cn/blog/?id=52</a></h2>
</body>
</html>
